<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="Model.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<script type="text/javascript">
function sbmit1(){	
    
		var memberID = document.getElementById("MemberID").value;
	    var memberName = document.getElementById("MemberName").value;	    
	    var memberAddress = document.getElementById("MemberAddress").value;
	    var memberOccupation = document.getElementById("MemberOccupation").value;
	    
	    var url = "../memberservlet";
	    var postParam = "MemberID=" + memberID + "&MemberName=" + memberName + "&MemberAddress=" + memberAddress 
	    + "&MemberOccupation=" + memberOccupation + "&opType=addMember";
	    var ajax = false;
// 	     alert(postParam);
	    if (window.XMLHttpRequest){
	        ajax = new XMLHttpRequest();
	        if (ajax.overrideMimeType) {
	            ajax.overrideMimeType("text/xml");
	        }
	    }else if (window.ActiveXObject){
	        try{
	            ajax = new ActiveXObject("Msxml2.XMLHTTP");
	        }catch(e){
	            try{
	                ajax = new ActiveXObject("Microsoft.XMLHTTP");
	            }catch (e){;}
	        }
	    }
	    if (!ajax) {
	        window.alert("不能创建XMLHttpRequest对象实例.");            
	        return false;
	    }
	    ajax.open("POST", url, true);
	    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    ajax.send(postParam);    
	   	
	    ajax.onreadystatechange = function() {        	      
	    	if(ajax.readyState==4){
	    		if(ajax.responseText==1){
	    			alert("添加成功！");    			
	    		}
	    		else{
	    			alert("添加失败！");
	    		}
	    		        		
	    	}
			
	    }
	
}
function sbmit2(){	
	var operateID = document.getElementById("OpID").value;
    var operateMemberID = document.getElementById("MemID").value;
    var operateCardID = document.getElementById("CardID").value;
    var operateAccountTime = 10;
    var operateExpriationTime = 100;
    var operateRemainTime = document.getElementById("RemainTime").value;
    var url = "../operateservlet";
    var postParam = "OperateID=" + operateID +"&OperateMemberID=" + operateMemberID + "&OperateCardID=" + operateCardID 
    + "&OperateAccountTime=" + operateAccountTime + "&OperateExpriationTime=" 
    + operateExpriationTime + "&OperateRemainTime=" + operateRemainTime + "&opType=addOperate";
    
    var ajax = false;
//    alert(postParam);
   
   if (window.XMLHttpRequest){
       ajax = new XMLHttpRequest();
       if (ajax.overrideMimeType) {
           ajax.overrideMimeType("text/xml");
       }
   }else if (window.ActiveXObject){
       try{
           ajax = new ActiveXObject("Msxml2.XMLHTTP");
       }catch(e){
           try{
               ajax = new ActiveXObject("Microsoft.XMLHTTP");
           }catch (e){;}
       }
   }
   if (!ajax) {
       window.alert("不能创建XMLHttpRequest对象实例.");            
       return false;
   }
   ajax.open("POST", url, true);
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   ajax.send(postParam);  
   ajax.onreadystatechange = function() {        	      
   	if(ajax.readyState==4){
   		if(ajax.responseText==1){
   			alert("添加成功！");    			
   		}
   		else{
   			alert("添加失败！");
   		}   		        	
   	}		
   }
   
}
</script>
</head>
<body>
<div align="center">
<!-- 代码仅作测试后台功能用，具体业务实现当根据需求详改。 -->
		<form method="get" name="regform" action=".">
				<tr>					
					<td align="right" height="60"><p>办卡人ID</p></td>
					<td align="left"><input id="MemberID"
						name="MemberID" type="text" value=""></td>
						
					<td align="right" height="60"><p>办卡人姓名</p></td>
					<td align="left"><input id="MemberName"
						name="MemberName" type="text" value=""></td>
						
					<td align="right" height="60"><p>办卡人地址</p></td>
					<td align="left"><input id="MemberAddress"
						name="MemberAddress" type="text" value=""></td>
						
					<td align="right" height="60"><p>办卡人职业</p></td>
					<td align="left"><input id="MemberOccupation"
						name="MemberOccupation" type="text" value=""></td>

					<td align="center" height="60">&nbsp;</td>
					<td align="left" height="60">
					<input id="register" name="register" type="button" value="添加用户" onclick="sbmit1()"></td>

					<td align="right" height="60"><p>操作ID</p></td>
					<td align="left"><input id="OpID"
						name="OpID" type="text" value=""></td>
						
					<td align="right" height="60"><p>办卡人ID</p></td>
					<td align="left"><input id="MemID"
						name="MemID" type="text" value=""></td>

					<td align="right" height="60"><p>所办卡ID</p></td>
					<td align="left"><input id="CardID"
						name="CardID" type="text" value=""></td>
						
					<td align="right" height="60"><p>剩余次数</p></td>
					<td align="left"><input id="RemainTime"
						name="RemainTime" type="text" value=""></td>
						
					
					<td align="center" height="60">&nbsp;</td>
					<td align="left" height="60">
					<input id="operate" name="operate" type="button" value="办卡" onclick="sbmit2()"></td>
				</tr>
			</form>
			</div>
</body>
</html>

